<?php

class Application_Model_Event {

    public static function venueToArray($venue) {
        $_events = array();
        $_event = array();
        $_event['title'] = '';
        $_event['url'] = '';
        $_event['venue'] = array(
            'name' => $venue->getName(),
            'location' => array(
                'city' => $venue->getLocation()->getCity(),
                'country' => $venue->getLocation()->getCountry(),
                'street' => $venue->getLocation()->getStreet(),
                'postalcode' => $venue->getLocation()->getPostalcode(),
                'point' => array(
                    'latitude' => $venue->getLocation()->getPoint()->getLatitude(),
                    'longitude' => $venue->getLocation()->getPoint()->getLongitude()
                )
            ),
            'url' => $venue->getUrl(),
            'website' => $venue->getWebsite()
        );
        $_event['artists'] = '';
        $_event['startDate'] = '';
        array_push($_events, $_event);
        return array('totalPages' => 0, 'events' => $_events);
    }

    public static function toArray($events) {
        $_events = array();
        $_event = array();
        foreach ($events['events'] as $event) {
            $_event['title'] = $event->getTitle();
            $_event['url'] = $event->getUrl();
            $_event['venue'] = array(
                'name' => $event->getVenue()->getName(),
                'location' => array(
                    'city' => $event->getVenue()->getLocation()->getCity(),
                    'country' => $event->getVenue()->getLocation()->getCountry(),
                    'street' => $event->getVenue()->getLocation()->getStreet(),
                    'postalcode' => $event->getVenue()->getLocation()->getPostalcode(),
                    'point' => array(
                        'latitude' => $event->getVenue()->getLocation()->getPoint()->getLatitude(),
                        'longitude' => $event->getVenue()->getLocation()->getPoint()->getLongitude()
                    )
                ),
                'url' => $event->getVenue()->getUrl(),
                'website' => $event->getVenue()->getWebsite()
            );
            $_event['artists'] = $event->getArtists();
            $_event['startDate'] = $event->getStartDate();
            array_push($_events, $_event);
        }
        return array('totalPages' => $events['totalPages'], 'events' => $_events);
    }

}

?>
